using System;
using Coderoom.ScrumPlanner.Data.Contracts;
using Coderoom.ScrumPlanner.Domain;
using Coderoom.ScrumPlanner.Resources;

namespace Coderoom.ScrumPlanner.Data
{
	public sealed class UserStoryService : Service<IUserStoryRepository>
	{
		public UserStoryService(IUserStoryRepository repository) : base(repository) { }

		public UserStoryCollection GetUserStories(Guid themeId)
		{
			return Repository.GetUserStories(themeId);
		}

		public UserStory GetUserStory(Guid userStoryId)
		{
			return Repository.GetUserStory(userStoryId);
		}

		public void CreateUserStory(UserStory userStory)
		{
			if (userStory == null)
				throw new ArgumentNullException("userStory");

			if (string.IsNullOrEmpty(userStory.Title))
				throw new ArgumentException(ExceptionMessages.ArgumentException_UserStoryTitleIsNullOrEmpty);

			Repository.CreateUserStory(userStory);
		}

		public bool DeleteUserStory(Guid userStoryId)
		{
			return Repository.DeleteUserStory(userStoryId);
		}
	}
}